package com.main;

import com.gryffonx.Interfaces.NPC.NPCList;
import com.gryffonx.Interfaces.dice.DiceRollerGUI;
import com.gryffonx.Interfaces.generators.NameGenerators;
import com.gryffonx.Interfaces.timeline.TimelineGenerator;
import com.gryffonx.utils.StringUtils;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;


/**
 * @author Erik Stell
 * @version 1.0
 */
public class MainInterfaceBinding {
    private JButton btnDiceTools;
    private JButton btnNameGen;
    private JPanel pnlMainPanel;
    private JButton btnNpc;

    public JButton getBtnNpc() {
        return btnNpc;
    }

    public void setBtnNpc(JButton btnNpc) {
        this.btnNpc = btnNpc;
    }

    public JButton getBtnTimelineGen() {
        return btnTimelineGen;
    }

    public void setBtnTimelineGen(JButton btnTimelineGen) {
        this.btnTimelineGen = btnTimelineGen;
    }

    private JButton btnTimelineGen;


    /**
     *
     */
    public MainInterfaceBinding() {
        //set look and feel
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        //action listeners
        btnNameGen.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                NameGenerators window = new NameGenerators("Name Generators");
                window.pack();
                int locationx = ((Toolkit.getDefaultToolkit().getScreenSize().width / 2));
                int windowWidth = (window.getWidth() / 2);
                int locationy = ((Toolkit.getDefaultToolkit().getScreenSize().height / 2));
                int windowHeight = (window.getHeight() / 2);
        
                window.setLocation(((Toolkit.getDefaultToolkit().getScreenSize().width / 2) -
                        (window.getWidth() / 2)),
                        ((Toolkit.getDefaultToolkit().getScreenSize().height / 2) -
                                (window.getHeight() / 2)));
                window.setVisible(true);
            }
        });
        ImageIcon appIcon = StringUtils.createImageIcon("/images/appIcon3.gif");
        btnNameGen.setIcon(appIcon);
        btnNameGen.setHorizontalAlignment(SwingConstants.LEFT);


        btnDiceTools.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                DiceRollerGUI window = new DiceRollerGUI("Dice Roller2");
                window.pack();
                int locationx = ((Toolkit.getDefaultToolkit().getScreenSize().width / 2));
                int windowWidth = (window.getWidth() / 2);
                int locationy = ((Toolkit.getDefaultToolkit().getScreenSize().height / 2));
                int windowHeight = (window.getHeight() / 2);

                window.setLocation(((Toolkit.getDefaultToolkit().getScreenSize().width / 2) -
                        (window.getWidth() / 2)),
                        ((Toolkit.getDefaultToolkit().getScreenSize().height / 2) -
                                (window.getHeight() / 2)));
                window.setVisible(true);
            }
        });
        ImageIcon diceIcon = StringUtils.createImageIcon("/images/diceIcon.gif");
        btnDiceTools.setIcon(diceIcon);
        btnDiceTools.setHorizontalAlignment(SwingConstants.LEFT);

        btnTimelineGen.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                TimelineGenerator window = new TimelineGenerator("Timeline Generator");
                window.pack();
                int locationx = ((Toolkit.getDefaultToolkit().getScreenSize().width / 2));
                int windowWidth = (window.getWidth() / 2);
                int locationy = ((Toolkit.getDefaultToolkit().getScreenSize().height / 2));
                int windowHeight = (window.getHeight() / 2);

                window.setLocation(((Toolkit.getDefaultToolkit().getScreenSize().width / 2) -
                        (window.getWidth() / 2)),
                        ((Toolkit.getDefaultToolkit().getScreenSize().height / 2) -
                                (window.getHeight() / 2)));
                window.setVisible(true);
            }
        });
        btnTimelineGen.setIcon(diceIcon);
        btnTimelineGen.setHorizontalAlignment(SwingConstants.LEFT);

        btnNpc.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                NPCList window = new NPCList("NPC Editor");
                window.pack();
                int locationx = ((Toolkit.getDefaultToolkit().getScreenSize().width / 2));
                int windowWidth = (window.getWidth() / 2);
                int locationy = ((Toolkit.getDefaultToolkit().getScreenSize().height / 2));
                int windowHeight = (window.getHeight() / 2);

                window.setLocation(((Toolkit.getDefaultToolkit().getScreenSize().width / 2) -
                        (window.getWidth() / 2)),
                        ((Toolkit.getDefaultToolkit().getScreenSize().height / 2) -
                                (window.getHeight() / 2)));                
                window.setVisible(true);
            }
        });
        btnNpc.setIcon(diceIcon);
        btnNpc.setHorizontalAlignment(SwingConstants.LEFT);
    }


    /**
     * @return
     */
    public JPanel getPnlMainPanel() {
        return pnlMainPanel;
    }

    /**
     * @param pnlMainPanel
     */
    public void setPnlMainPanel(JPanel pnlMainPanel) {
        this.pnlMainPanel = pnlMainPanel;
    }

    /**
     * @return
     */
    public JButton getBtnDiceTools() {
        return btnDiceTools;
    }

    /**
     * @param btnDiceTools
     */
    public void setBtnDiceTools(JButton btnDiceTools) {
        this.btnDiceTools = btnDiceTools;
    }

    /**
     * @return
     */
    public JButton getBtnNameGen() {
        return btnNameGen;
    }

    /**
     * @param btnNameGen
     */
    public void setBtnNameGen(JButton btnNameGen) {
        this.btnNameGen = btnNameGen;
    }

    /**
     *
     */
    public void setData() {
    }

    /**
     *
     */
    public void getData() {
    }

    /**
     * @return
     */
    public boolean isModified() {
        return false;
    }

    private void createUIComponents() {
        // TODO: place custom component creation code here 
    }
}
